#pragma strict

function Start () {
	time_passed = 0;
}

function Update () {
	time_passed += Time.deltaTime;
	
	if (time_passed > popup_time_limit)
	{
		SceneManager.Instance().PopupEnded(popup_resume_game);
		Destroy(gameObject);
	}
}

private var time_passed:float;
var popup_height:int = 0;
var popup_width:int = 0;
var popup_text:String = "";
var popup_time_limit:float = 4;
var popup_resume_game:boolean;

function OnGUI() {	
	GUILayout.BeginArea(Rect(Screen.width/2 - popup_width/2, Screen.height/2 - popup_height/2, popup_width, popup_height));
		GUILayout.BeginVertical("box");
			var old_align:TextAnchor  = GUI.skin.label.alignment;
			GUI.skin.label.alignment = TextAnchor.MiddleCenter;			
			GUILayout.Label(popup_text);
			GUILayout.Label((parseInt(popup_time_limit - time_passed)).ToString());
			GUI.skin.label.alignment = old_align;
		GUILayout.EndVertical();
	GUILayout.EndArea();
}